import { h } from 'vue'
import { ElTag } from 'element-plus'

// 搜索配置
export const searchConfig = [
  { field: 'keyword', label: '关键词', component: 'Input', placeholder: '任务名 / 类路径' },
  {
    field: 'group',
    label: '分组',
    component: 'Input',
    placeholder: '请输入分组名称',
  },
  {
    field: 'status',
    label: '状态',
    component: 'Select',
    placeholder: '请选择',
    options: [
      { label: '全部', value: '' },
      { label: '运行中', value: 'RUNNING' },
      { label: '已暂停', value: 'PAUSED' },
    ],
  },
]

// 表格列配置
export const tableConfig = [
  { prop: 'name', label: '任务名', width: 150 },
  { prop: 'description', label: '描述', width: 150 },
  { prop: 'classPath', label: 'Job类路径', width: 300, 'show-overflow-tooltip': true },
  { prop: 'cron', label: 'Cron表达式', width: 160 },
  {
    prop: 'status',
    label: '状态',
    width: 120,
    render: (row) => {
      const type = row.status === 'RUNNING' ? 'success' : 'warning'
      const text = row.status === 'RUNNING' ? '运行中' : '已暂停'
      return h(ElTag, { type, size: 'small', effect: 'light' }, () => text)
    },
  },
  { prop: 'lastRunAt', label: '上次执行时间', width: 180 },
  { prop: 'nextRunAt', label: '下次执行时间', width: 180 },
  { prop: 'group', label: '分组', width: 120 },
]
